<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body style="font-size:30px;">
    <script>
        var endTime = new Date("2016/12/31 18:00:00");//12.31日00点
            // alert(endTime.getTime())//2016.12.31距 1970的时间  毫秒数
        function getTime(){
            var nowTime = new Date();
            // alert(nowTime.getTime())//现在 距 1970的时间  毫秒数
            var seconds = (endTime.getTime()-nowTime.getTime())/1000;//总秒数
            var day = Math.floor(seconds/60/60/24);
            day<10?day = "0"+day:day = day;
            var hour = Math.floor(seconds/60/60%24);
            hour<10?hour = "0"+hour:hour = hour;
            var minute = Math.floor(seconds/60%60);
            minute<10?minute = "0"+minute:minute=minute;
            var second = Math.floor(seconds%60);
            second<10?second = "0"+second:second=second;
            document.body.innerHTML = "距离元旦放假还有："+day+"天"+hour+"小时"+minute+"分"+second+"秒";
        }
        setInterval(getTime,1000)
    </script>
</body>
</html>